<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>229990309黄欣绮</title>
</head>
<body>
    <style>
        .box{
            width: 360px;
            border: 1px;
            text-align: center;
            margin-left: auto;
            margin-right: auto;
            margin-top: 30px;
        }
        #id{
            width: 152px;
            height: 28px;
            line-height: 28px;
            font-size: 14px;
            text-align: center;
        }
        #birth{
            width: 152px;
            height: 28px;
            line-height: 28px;
            font-size: 14px;
            text-align: center;
            border: 1px solid;
            margin-left: auto;
            margin-right: auto;
        }
        #btn{
            width: 78px;
            height: 28px;
            font-size: 14px;
            margin-top: 20px;
        }
    </style>
    <div class="box">
        <input type="text" id="id" placeholder="请输入身份证号" value="">
        <input type="text" id="birth" value="" placeholder="生日日期" readonly>
        <button id="btn">转换</button>
    </div>
    <script>
        function getBirth(id){
            var year=id.slice(6,10);
            var mouth=id.slice(10,12);
            var day=id.slice(12,14);
            return `${year}年${mouth}月${day}日`;
        }
        btn.addEventListener("click",function(event){
            var id=document.getElementById("id");
            var value=id.value;
            var birth=document.getElementById("birth");
            var btn=document.getElementById("btn");
            birth.value=getBirth(value);
        })
    </script>
</body>
</html>